<!DOCTYPE html>
<html>

<head lang="en">
    <title>找攻略</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/strategy.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>

</head>
<script>
    $(function () {

        //获取传过来的参数并进行解码
        var search = unescape(getParams().search);

        //内容添加到当前页面的输入框中
        if (search!=null) {//当接收参数不为空时才进行设置
            $("#searchBtn").val(search);
        }
        //通过参数获取相关的游记
        $.ajax({
            url: baseUrl + "/travels/{search}",
            type: 'post',
            data: {search: search},
            success: function (data) {
                //渲染数据
                $("#pills-2").renderValues(data, {
                    getTravel: getHref,
                    getUser:getHref

                });
            }
        });
        //通过获取相关的攻略
        $.ajax({
            url: baseUrl + "/strategies/{search}",
            type: 'post',
            data: {search: search},
            success: function (data) {
                //渲染数据
                $("#pills-1").renderValues(data, {
                    getStrategy: getHref
                })
            }
        });


        //定义全局变量获取搜索框内容
        var newSearch;
        /*$("#searchBtn").val('');*/
        //给搜索框绑定点击事件
        $("#searchBtn").click(function () {
            //获取搜索框的内容
            newSearch = $(this).val();
        });

        //给搜索按钮绑定点击事件
        $("#buttonSearch").click(function () {
            //调用点击事件
            $("#searchBtn").click();
            console.log(newSearch);
            if (newSearch) {
                //通过参数获取相关的游记
                $.ajax({
                    url: baseUrl + "/travels/{search}",
                    type: 'post',
                    data: {search: newSearch},
                    success: function (data) {
                        //渲染数据
                        $("#pills-2").renderValues(data, {
                            getTravel: getHref
                        });
                    }
                })
                //通过获取相关的攻略
                $.ajax({
                    url: baseUrl + "/strategies/{search}",
                    type: 'post',
                    data: {search: newSearch},
                    success: function (data) {
                        //渲染数据
                        $("#pills-1").renderValues(data, {
                            getStrategy: getHref
                        })
                    }
                })
            }
        })
    });

</script>
<body style="background: url('/upload/2.bmp')">
<div class="search-head" style="background: url('/upload/2.bmp')">
    <div class="row nav-search" >
        <div class="col-1">
            <a href="index.html">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-10">
            <div class="input-group-sm search" id="searchFrame">
                <input class="form-control" id="searchBtn" placeholder="找攻略">
            </div>
            <a href="#">
                <i class="fa fa-search" id="buttonSearch"
                   style="color:white;font-size:25px;position: absolute;top: 23%;left: 92%">
                </i>
            </a>
        </div>
        <div class="col-1">
            <!--<button class="btn" id="buttonSearch">搜索</button>-->
        </div>
    </div>
</div>

<ul class="nav nav-pills nav-justified border border-left-0 border-top-0 border-right-0" id="pills-tab" role="tablist">
    <!--<li class="nav-item">
        <a class="nav-link active show" data-toggle="pill" href="#pills-1">
            <span style="font-weight: bold;">攻略</span>
        </a>
    </li>-->
    <li class="nav-item">
        <a class="nav-link active show" data-toggle="pill" href="#pills-1"><span style="font-weight: bold;">攻略</span></a>
    </li>
    <li class="nav-item">
        <a class="nav-link" data-toggle="pill" href="#pills-2"><span style="font-weight: bold;">游记</span></a>
    </li>
</ul>

<div class="container tab-content" id="pills-tabContent">
    <div class="tab-pane fade active show" id="pills-1">
        <div class="container strategyCommend">
            <div class="row hot" render-loop="list">
                <div class="col-12">
                    <a data-url="strategyCatalogs.html?id=" render-fun="getStrategy" render-key="list.id">
                        <img render-src="list.coverUrl">
                        <p render-html="list.title">成都攻略</p>
                    </a>
                </div>
            </div>
        </div>
    </div>
    <!--游记-->
    <div class="tab-pane fade" id="pills-2">
        <div id="allTravels">
            <div render-loop="list">
                <div class="row detail">
                    <div class="col">
                        <a data-url="travelContent.html?id=" render-fun="getTravel" render-key="list.id">
                            <h4 render-html="list.title"> 骨灰级成都吃货地图1</h4>
                        </a>
                        <p>
                            <a data-url="userProfiles.html?id=" render-fun="getUser" render-key="list.author.id">
                                <img class="rounded-circle head-img" render-src="list.author.headImgUrl" width="30px">
                                <span render-html="list.author.nickName">喵喵</span> </a> 在
                            <span class="addr" render-html="list.place.name">成都</span>

                        </p>
<!--                        <p>-->
<!--                            <i class="fa fa-eye fa-fw"></i>-->
<!--                            <span id="pageView">0</span>-->
<!--                            <i class="fa fa-commenting fa-fw"></i>-->
<!--                            <span>0</span>-->
<!--                        </p>-->
                    </div>
                    <div class="col bigimg">
                        <a data-url="travelContent.html?id=" render-fun="getTravel" render-key="list.id">
                            <img render-src="list.coverUrl" width="150px">
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


</body>

</html>